package com.company;

import java.awt.image.BufferedImage;

/**
 * Created by v on 17-7-9.
 */
public abstract class Flyer {
    protected int x;
    protected int y;

    protected int width;
    protected int height;

    protected BufferedImage image;

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public BufferedImage getImage() {
        return image;
    }

    public void setImage(BufferedImage image) {
        this.image = image;
    }

    /**
     * 下一步动作
     */
    public abstract void step();

    /**
     *
     * @return 返回是否越界
     */
    public abstract boolean outOfBound();

    /**
     *
     * @param bullet 子弹
     * @return 如果被传来的子弹撞上了，则返回true
     */
    public boolean bulletCollision(Bullet bullet){
        return bullet.x>x&&bullet.x<x+width
                &&bullet.y>y&&bullet.y<y+height;
    }
}
